<%--
  Created by IntelliJ IDEA.
  User: zheng
  Date: 2021/6/26
  Time: 16:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/png" sizes="16px" href="${pageContext.request.contextPath}/statics/images/icon.png"/>
    <title>芜湖起飞 - 订单选择</title>
    <script src="${pageContext.request.contextPath}/statics/js/jquery-3.6.0.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/login.css"/>
</head>
<body>
<h1 class="logo"><img src="${pageContext.request.contextPath}/statics/images/icon.png" width="45px"><a class="photo">芜湖起飞</a>
</h1>
${userCome}
<div class="container-fluid">
    <div class="row bg">
        <div class="welcome col-sm-offset-1 col-sm-5 col-md-offset-2 col-md-4 col-lg-offset-1 col-lg-4">
            <div class="title">
                <div>欢迎来到</div>
                <div>芜湖起飞</div>
            </div>

            <p class="comment"><br/>汉服，全称是“汉民族传统服饰”，又称汉衣冠、汉装、华服，
                是从黄帝即位到公元17世纪中叶（明末清初），
                在汉族的主要居住区，以“华夏－汉”文化为背景和主导思想，
                以华夏礼仪文化为中心，通过自然演化而形成的具有独特汉民族风貌性格。
            </p>
        </div>
        <form class="col-xs-offset-2 col-xs-8 col-md-5 col-sm-offset-1 col-sm-4 col-lg-3 entrance"
             style="height: 80%; display: flex;flex-direction: column;justify-content: center;align-items: center;" id="D-form">

            <p style="font-size: 18px">请选择你所乘坐的航班</p>
            <select class="order-choose" id="order" style="width: 65%;margin: 20px"  name="ids">
                <c:forEach items="${flight}" var="item">
                    <option value="${item.flight_id}">${item.flight_no} - ${item.flight_start}->${item.flight_end}</option>
                </c:forEach>
            </select>
            <button class="subtn" id="chbtn" style="box-shadow: 2px 2px 12px #CCf;margin-top: 30px" onclick="determine()" type="button">确定选择</button>
        </form>
    </div>


    <div class="footer">
        <a href="https://beian.miit.gov.cn/">粤ICP备2020103045号</a>
        <a>第一实训小组作业-芜湖起飞</a>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>
</body>

<script>
    function determine(){
        $.ajax({
            url:"${pageContext.request.contextPath}/features/choose-ticket.do",
            type:"POST",
            dataType:"json",
            data:$("#D-form").serialize(),
            success:function (data){
                console.log(data);
                if(data.code == "0"){
                    window.location.href = "${pageContext.request.contextPath}/features/${type}";
                }else{
                    var con = confirm(data.message);
                    if(con == true){
                        buyTicket();
                    }
                }
            }
        });

        function buyTicket(){
            $.ajax({
                url:"${pageContext.request.contextPath}/features/buy-ticket.do",
                type: "POST",
                data: $("#D-form").serialize(),
                dataType: "json",
                success:function (data) {
                    console.log(data);
                    if(data.code == "0"){
                        alert(data.message);
                    }else{
                        alert(data.message);
                        window.location.href="${pageContext.request.contextPath}/features/${type}"
                    }
                }
            });
        }
    }
</script>
</html>
